//
// Created by 段大志 on 16/4/23.
// Copyright (c) 2016 BMProject. All rights reserved.
//

#import "DataModel.h"
#import "NSDate+Utils.h"
#import "BackgroundBizDisCell.h"
#import "BackgroundDealVc.h"
#import "BackgroundDispalyVc.h"

@interface BackgroundBizDisCell () {
    BackViewWrapModel *_backViewWrapModel;
}
@property(weak, nonatomic) IBOutlet UIView *bgView;
//背景
@property(weak, nonatomic) IBOutlet UILabel *titleLabel;
//标题
@property(weak, nonatomic) IBOutlet UILabel *timeLabel;
//时间
@property(weak, nonatomic) IBOutlet UILabel *sponsorLabel;
//发起者
@property(weak, nonatomic) IBOutlet UILabel *acceptLabel;
//接受者
@property(weak, nonatomic) IBOutlet UILabel *contentLabel;//内容



@end

@implementation BackgroundBizDisCell {

}

- (void)awakeFromNib {
    [super awakeFromNib];
    self.bgView.layer.cornerRadius = 5.0;
    self.bgView.layer.masksToBounds = YES;
}

- (void)setCellInfo:(BackViewWrapModel *)info andPosition:(NSInteger)position {
    _backViewWrapModel = info;
    BackMessListModel *model = info.backMessList[position];
    [self setInfoWithBackMessListModel:model];
}

- (void)setInfoWithBackMessListModel:(BackMessListModel *)backMessListModel {

    if ([backMessListModel isKindOfClass:[NSDictionary class]]) {
        backMessListModel = [[BackMessListModel alloc] initWithDictionary:((NSDictionary *) backMessListModel) error:nil];
    }

    self.titleLabel.text = [NSString stringWithFormat:@"标题:%@", [NSString ignoreEmptyStr:backMessListModel.title]];
    self.timeLabel.text = [NSString stringWithFormat:@"时间:%@", [NSString ignoreEmptyStr:([[NSDate dateWithString:backMessListModel.creatTime formatString:@"yyyyMMddHHmmss"] formatStringWithFormat:@"yyyy-MM-dd"])]];//时间
    self.acceptLabel.text = [NSString stringWithFormat:@"接受者:%@", @""];
    self.sponsorLabel.text = [NSString stringWithFormat:@"发送者:%@", @""];
    self.contentLabel.text = [NSString stringWithFormat:@"内容:%@", [NSString ignoreEmptyStr:backMessListModel.message]];

    //sendtype=0那userId肯定取的是sysmap里的了，sendtype=1取的肯定是websitename的信息
    BlackUserMapModel *userMapModel = _backViewWrapModel.userMap;
    if (backMessListModel.sendType.intValue == 0) {//管理员发出
        self.sponsorLabel.text = [NSString stringWithFormat:@"发送者:%@", userMapModel.sysUser];
        self.acceptLabel.text  = [NSString stringWithFormat:@"接受者:%@", userMapModel.websiteName];
    } else {//门店发出
        self.sponsorLabel.text = [NSString stringWithFormat:@"发送者:%@", userMapModel.websiteName];
        self.acceptLabel.text  = [NSString stringWithFormat:@"接受者:%@", userMapModel.sysUser];
    }
}

@end